package com.yj.web.WeChat.api;

import com.yj.web.WeChat.Bean.WxMaterial;
import com.yj.web.WeChat.Bean.WxMaterialNews;
import com.yj.web.WeChat.Bean.WxMaterialUploadResult;
import com.yj.web.WeChat.Bean.WxUser;
import com.yj.web.WeChat.Bean.material.WxMediaImgUploadResult;
import com.yj.web.util.WxErrorException;

import java.io.File;
import java.io.IOException;

/**
 * Created by yanlinyang on 2017/9/10.
 */
public interface WxService {

    public boolean checkSignature(String timestamp, String nonce, String signature);

    public String getAccessToken() throws WxErrorException;
    public String getAccessToken(boolean forceRefresh) throws WxErrorException;

    //上传永久图文素材
    public WxMaterialUploadResult materialNewsUpload(WxMaterialNews news) throws WxErrorException;
    //获取图文永久素材的信息
    public WxMaterialNews materialNewsInfo(String media_id) throws WxErrorException;

    public WxUser userInfo(String openid, String lang) throws WxErrorException;

    void setRetrySleepMillis(int retrySleepMillis);
    void setMaxRetryTimes(int maxRetryTimes);

    public WxMaterialUploadResult materialFileUpload(String mediaType, WxMaterial material) throws WxErrorException;
    /**
     * <pre>
     * 上传图文消息内的图片获取URL
     * 请注意，本接口所上传的图片不占用公众号的素材库中图片数量的5000个的限制。图片仅支持jpg/png格式，大小必须在1MB以下。
     * 详情请见: <a href="http://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444738729&token=&lang=zh_CN">新增永久素材</a>
     * 接口url格式：https://api.weixin.qq.com/cgi-bin/media/uploadimg?access_token=ACCESS_TOKEN
     * </pre>
     *
     * @param file 上传的文件对象
     * @return WxMediaImgUploadResult 返回图片url
     * @throws WxErrorException
     */
//    WxMediaImgUploadResult mediaImgUpload(File file) throws WxErrorException;

    public WxMaterialUploadResult uploadMaterial(String mediaType, String fileType, String fileName) throws WxErrorException, IOException;
    public WxMaterialUploadResult addNews(String author, String thumbMediaId, String title, String content, String contentSourceUrl,
                                          boolean showCoverPic, String digest) throws WxErrorException;
}
